Regexp (object text)

Hello,

I'm trying to parse Object Text to create an external link I have written everything but I having trouble with the Regexp, any help would be appreciated.

I would like to validate that the string is in the correct syntax separated by a semi colon. I would also like to validate the path (syntax: url,\\10.155.,?:\, etc.)
 

Regexp URL = regexp2 "??????"
string txt3 = "name;description;(outward or inward);(openAsURL or none);path"
if (URL txt3) 
{
    print txt3[match 0] "\n" // first section in ()
        print txt3[match 1] "\n" // second section in ()
        print txt3[match 2] "\n" // third section in ()
        print txt3[match 3] "\n" // fourth section in ()
        print txt3[match 4] "\n" // fifth section in ()
}

SystemAdmin - Thu Aug 16 21:06:42 EDT 2012

Re: Regexp (object text)
SystemAdmin - Fri Aug 17 02:37:56 EDT 2012

Without additional details, this is how I interpreted your question:
RegExp to extract 5 strings separated by colons.
 

Regexp URL = regexp2 "^([^;]*);([^;]*);([^;]*);([^;]*);(.*)$"
string txt3 = "name;description;(outward or inward);(openAsURL or none);path"
if (URL txt3) 
{
    print txt3[match 0] "\n" // full match
        print txt3[match 1] "\n" // first section in ()
        print txt3[match 2] "\n" // second section in ()
        print txt3[match 3] "\n" // third section in ()
        print txt3[match 4] "\n" // fourth section in ()
        print txt3[match 5] "\n" // fifth section in ()
}

 


Only match5 may contain colons.
It does not validate any of the values, but you could do that separatly.

 

Re: Regexp (object text)
SystemAdmin - Fri Aug 17 02:49:54 EDT 2012

Or maybe you want this

Regexp URL = regexp2 "^([^;]*);([^;]*);(outward|inward);(openAsURL|none);(.*)$"
string txt3 = "name;description;outward;none;path;and;more"
if (URL txt3) 
{
    print txt3[match 0] "\n" // full match
        print txt3[match 1] "\n" // first section in ()
        print txt3[match 2] "\n" // second section in ()
        print txt3[match 3] "\n" // third section in ()
        print txt3[match 4] "\n" // fourth section in ()
        print txt3[match 5] "\n" // fifth section in ()
}

Re: Regexp (object text)
SystemAdmin - Fri Aug 17 08:26:24 EDT 2012

SystemAdmin - Fri Aug 17 02:49:54 EDT 2012

Or maybe you want this

Regexp URL = regexp2 "^([^;]*);([^;]*);(outward|inward);(openAsURL|none);(.*)$"
string txt3 = "name;description;outward;none;path;and;more"
if (URL txt3) 
{
    print txt3[match 0] "\n" // full match
        print txt3[match 1] "\n" // first section in ()
        print txt3[match 2] "\n" // second section in ()
        print txt3[match 3] "\n" // third section in ()
        print txt3[match 4] "\n" // fourth section in ()
        print txt3[match 5] "\n" // fifth section in ()
}

Hello,

Thank you for the response, that is what I was looking for. My only question now is the a way of validating the path(syntax) like if it is a URL that it is correctly written or a network path, etc. I now that it will be hard to catch all incorrectly written paths but I would like to catch 80-90% of the mistakes(typos) prior to create the External Link. Once again thank you for all the help.

-Jim

Re: Regexp (object text)
llandale - Fri Aug 17 11:45:51 EDT 2012

SystemAdmin - Fri Aug 17 02:49:54 EDT 2012

Or maybe you want this

Regexp URL = regexp2 "^([^;]*);([^;]*);(outward|inward);(openAsURL|none);(.*)$"
string txt3 = "name;description;outward;none;path;and;more"
if (URL txt3) 
{
    print txt3[match 0] "\n" // full match
        print txt3[match 1] "\n" // first section in ()
        print txt3[match 2] "\n" // second section in ()
        print txt3[match 3] "\n" // third section in ()
        print txt3[match 4] "\n" // fourth section in ()
        print txt3[match 5] "\n" // fifth section in ()
}

I'm brain dead with Regular expressions, and so need to format them like this:

string re_sExternal =     "^"         //      beginning of string     -
                        "([^;]*)"             // match 1              -
                        ";"           //              -
                        "([^;]*)"             // match 2              -
                        ";"           //              -
                        "(outward|inward)"    // match 3              -
                        ";"           //              -
                        "(openAsURL|none)"    // match 4              -
                        ";"           //              -
                        "(.*)"                // match 5              -
                        "$"           //      end of string
print "re_sExternal = [" re_sExternal "]\n"
Regexp  re_External = regexp2(re_sExternal)


It makes it easier to grasp and debug for me.

-Louie

Be sure to test with strings containing EOLs before and after the desired sequence.